﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace Retrofit.Core
{
    public enum LogCategory
    {
        Game,
        Content,
        Exception
    }

    public static class Log
    {
        private static List<string> m_lines = new List<string>();

        [Conditional("DEBUG")]
        public static void WriteLine(LogCategory category, string message)
        {
            string line = string.Format("[Log] {0} : {1}",category.ToString(),message);
            Debug.WriteLine(line);
            m_lines.Add(line);
        }


        public static void SaveFile(string filename)
        {
            //TODO: Create Log Folder.
            string fullpath = Path.Combine(Environment.CurrentDirectory, filename + GetDate() + ".txt");

            using (TextWriter writer = new StreamWriter(fullpath))
            {
                writer.WriteLine(DateTime.Now);
                for (int i = 0; i < m_lines.Count; i++)
                {
                    writer.WriteLine(m_lines[i]);
                }

                writer.Close();
            }
        }

        public static string GetDate()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(DateTime.Now.Month);
            sb.Append(DateTime.Now.Day);
            sb.Append(DateTime.Now.Year);
            sb.Append(DateTime.Now.Hour);
            sb.Append(DateTime.Now.Minute);
            return sb.ToString();
        }
    }
}
